<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
        <title><?php echo $title ?></title>
        <link rel="stylesheet" href="<?php echo base_url(); ?>media/bootstrap/css/bootstrap.css">
        <style type="text/css">
            body {
                padding-top: 20px;
                padding-bottom: 40px;
            }
            /* Custom container */
            .container-narrow {
                margin: 0 auto;
                max-width: 700px;
            }
            .container-narrow > hr {
                margin: 30px 0;
            }
            /* Main marketing message and sign up button */
            .jumbotron {
                margin: 60px 0;
                text-align: center;
            }
            .jumbotron h1 {
                font-size: 72px;
                line-height: 1;
            }
            .jumbotron .btn {
                font-size: 21px;
                padding: 14px 24px;
            }
            /* Supporting marketing content */
            .marketing {
                margin: 60px 0;
            }
            .marketing p + h4 {
                margin-top: 28px;
            }



            #upload_form.positioned {

                position: absolute;

                top: 250px;

                left: 50%;

                margin-top: auto;

                margin-bottom: auto;

                margin-left: -225px;

                z-index: 1000;

                display: none;

            }

            #loading {

                clear: both;

                background: url('<?php echo base_url(); ?>media/image/ajax-loader-1.gif') no-repeat;

                width: 126px;

                height: 22px;

                float: right;

            }

            .overlay{

                display:none;

                position:fixed;

                top:0px;

                left:0px;

                right:0px;

                bottom:0px;

                z-index:4;

                background:#000;

                opacity:0.8;

            }

            .hiddenupload {

                display:none;

            }

        </style>
        <link rel="stylesheet" href="<?php echo base_url(); ?>media/bootstrap/css/bootstrap-responsive.css">
        <link rel="stylesheet" href="<?php echo base_url(); ?>media/css/additional.css">
        <script src="<?php echo base_url();?>media/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>media/js/tinymce/tinymce.min.js"></script>
        <script type="text/javascript">
            tinymce.init({
                selector: "textarea",
                height:"800",
                plugins: [
                    "ajaximage advlist autolink link image lists charmap  preview hr anchor pagebreak ",
                    "searchreplace  visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                    "save table contextmenu directionality emoticons template paste textcolor"
                ]

            });
        </script>

        <script type="text/javascript">

            $(document).ready(function() {

                $('#upload_form').addClass( 'positioned' ); // positions the hidden form, I didn't need to use a separate class but I'm using the positioned class elsewhere so I did..

                $('a.cancel').click( function(e) { // close the form when cancel is clicked

                    e.preventDefault();

                    $('#status_output').empty();

                    $("#upload_form").fadeOut('fast');

                    $("#overlay").fadeOut('fast');

                });

 

                $('#uploadform').submit(function(e) { // the form submit..

                    e.preventDefault();

                    var idata = new FormData(this);

                    var scriptUrl = $(this).attr('action');

                    $('#status_output').empty();

                    $('#buttons').hide();

                    $('#loading').show();

 

                    $.ajax({

                        url: scriptUrl,

                        data: idata,

                        cache: false,

                        contentType: false,

                        processData: false,

                        type: 'POST',

                        success: showResponse // callback function for handling the server response

                    });

                    return false;

                });

            });

 

            function showResponse(data)  { 

                // check if the response message indicated a problem on the server side

                var result;

                result = data.indexOf("Error"); // see if I returned 'error' in the server response

                $('#loading').hide(); 

                if(result == -1) // everything was successful

                {

                    tinyMCE.execCommand('mceInsertContent', false, data); //insert the returned html in the editor instance

                    $("#upload_form").fadeOut('fast', function(){ // and close/reset the upload form

                        $("#overlay").fadeOut('fast');

                        $('#uploadform')[0].reset();

                        $('#status_output').empty();

                        $('#buttons').show();

                    }); 

                }

                else // problem was found

                {

                    $('#loading').fadeOut('fast', function(){

                        $('#buttons').fadeIn('fast');

                        $('#status_output').html(data); // put the server response in the status output div

                    });

                }

            }

        </script>

    </head>
    <body>
        <div class="container-narrow">

            <div class="masthead">
                <ul class="nav nav-pills pull-right">

                    <?php if ($this->ion_auth->logged_in()): ?>
                        <li class="dropdown">    
                            <a class="dropdown-toggle" id="drop3" role="button" data-toggle="dropdown" href="#">Редактировать <b class="caret"></b></a>
                            <ul id="menu1" class="dropdown-menu" role="menu" aria-labelledby="drop4">
                                <li role="presentation"><a role="menuitem" tabindex="-1" href="<?php echo site_url('admin/admin/pages'); ?>">Редактировать статьи</a></li>
                                <li role="presentation"><a role="menuitem" tabindex="-1" href="<?php echo site_url('admin/admin/page_add'); ?>">Добавить статью</a></li> 
                                <li role="presentation"><a role="menuitem" tabindex="-1" href="<?php echo site_url('admin/admin/cats'); ?>">Редактировать категории</a></li>
                            </ul>
                        </li>
                        <li class="dropdown">    
                            <a class="dropdown-toggle" id="drop2" role="button" data-toggle="dropdown" href="#">Пользователи <b class="caret"></b></a>
                            <ul id="menu1" class="dropdown-menu" role="menu" aria-labelledby="drop4">
                                <li role="presentation"><a role="menuitem" tabindex="-1" href="<?php echo site_url('admin/admin/users'); ?>">Пользователи</a></li>
                                <li role="presentation" class="divider"></li>
                                <li role="presentation"><a role="menuitem" tabindex="-1" href="<?php echo site_url('admin/admin/logout'); ?>">Выход</a></li>
                            </ul>
                        </li>


                    <?php endif; ?>

                </ul>
                <h3 class="muted">Мой сайт</h3>

            </div>
            <hr>
            <?php if (!empty($message)): ?>
                <div class="alert alert-info">
                    <?php echo $message; ?>
                </div>
            <?php endif; ?>

